package org.box.metadata.shell.web.server;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class ServerCallback {
	
	public ServerCallback(ShellOutStream stream, int lastIndex, String sessionId, boolean busy) {
		this.consoleBusy = busy;
		
		records = new ArrayList<LogRecord>();
		for (LogRecord r : stream.getRecords()) {
			if (r.getIndex() > lastIndex && 
					(r.getSession() == null || r.getSession().equals(sessionId)))
				records.add(r);
		}
	}

	private final boolean consoleBusy;
	private final List<LogRecord> records;

	public List<LogRecord> getRecords() {
		return records;
	}

	public boolean isConsoleBusy() {
		return consoleBusy;
	}

}
